#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
typedef struct node{
    int v, k, c, l;
}Node;
Node A[maxn];
int s[maxn];
int N;
int dp[maxn];
bool cmp(Node&a, Node&b){return a.v < b.v;}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int kase = 0;
    while(cin >> N && N){
        for (int i = 0; i < N; ++i) {
            cin >> A[i].v >> A[i].k >> A[i].c >> A[i].l;
        }

        sort(A, A+N, cmp);
        dp[0] = A[0].k + A[0].l*A[0].c;
        s[0] = A[0].l;
        for (int i = 1; i < N; ++i) {
            s[i] = s[i-1] + A[i].l;
            for (int j = -1; j < i; ++j) {
                if(j==-1) dp[i] = s[i] * A[i].c + A[i].k;
                else{
                    dp[i] = min(dp[i], dp[j] + (s[i]-s[j])*A[i].c + A[i].k);
                }
            }
        }
//        if(kase++) cout << "\n";
        cout << dp[N-1] << endl;
    }
    return 0;
}